package com.net.shop.car.manager.ui.viewholder;

import java.util.List;

import com.net.shop.car.manager.BaseActivity;
import com.net.shop.car.manager.R;
import com.net.shop.car.manager.utils.StringUtils;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class TelsAdpater extends BaseAdapter {
	private BaseActivity activity;
	
	private List<String> tels;

	public TelsAdpater(List<String> tels,BaseActivity activity) {
		this.tels = tels;
		this.activity = activity;
	}

	@Override
	public int getCount() {
		return tels == null ? 0 : tels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View curentView = convertView;
		final String telNum = tels.get(position);
		if (curentView == null) {
			curentView = activity.inflater.inflate(
					R.layout.item_tel_layout, parent, false);
			curentView.setTag(new TelItemViewHolder(curentView));
		}
		TelItemViewHolder telItemViewHolder = (TelItemViewHolder) curentView
				.getTag();
		telItemViewHolder.desTextView.setText("联系电话" + StringUtils.parseIntToCNStr(position) + "线");
		telItemViewHolder.telNum.setText(telNum);
		telItemViewHolder.telBtn
				.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						activity.call(telNum);
					}
				});
		return curentView;
	}

}
